<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5 Transitional//EN">
<%@ page pageEncoding="UTF-8" %>
<%@ page import="jp.co.technotree.apl.api.common.Message" %>
<%@page import="jp.co.technotree.apl.api.common.FwCom"%>
<%@page import="jp.co.technotree.apl.cmd.use.Use2000Bean"%>
<jsp:useBean id="formBean" class="jp.co.technotree.apl.cmd.use.Use2000Bean" scope="request" />
<%
	String strOutputCate = formBean.getOutputCate(); //1=初回モード 2=入荷中モード 3=完了モード 4=キャンセルモード

%>
<html>
<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="apple-mobile-web-app-capable" content="yes"/>
<link rel='stylesheet' type='text/css' href='../../common/css/use/use2000.css' >
<link rel='stylesheet' type='text/css' href='../../common/css/popUp.css' >

<script type='text/javascript' src='../../common/js/popUp.js'></script>
<script type='text/javascript' src='../../common/js/NumKeyBoard2.js'></script>


<style type="text/css">

	.mainTbl_Left{
		 border: 0px solid #CCCCFF;
		 height:100px;
		 width: 180px;
		 margin-top:-250px;
		 align:center;
	}

	.mainTbl_Right{
		 border: 0px solid #CCCCFF;
		 height:550px;
	}


	.selTitle{
	 font-size:16px;
	 valign:middle;

	}

	.ImageZone{
	 position:absolute;
	 top :115px;
	 right:20px;
	 visibility: visible;

	 width: 200px;
	 height:200px;
	}


	.bottomBtn{
	 position:absolute;
	 bottom :60px;
	 right:10px;
	 visibility: visible;

	 width: 500px;
	 height:50px;
	}


	.OrderReason{
	 position:absolute;
	 top :80px;
	 left:640px;
	 visibility: visible;

	 width: 320px;
	 height:200px;
	}

	.backBtn{
		width: 80px;
		height:50px;
		font-size:18px;
		margin-top:1px;
		background-image: -webkit-gradient(linear, left top, left bottom, from(#6699CC), to(#6699CC),color-stop(0.7,#6688CC));
		color: #fff;
		font-weight:bold;
		text-shadow: -1px 2px rgba(0,0,0,0.2);
		-webkit-border-radius:10px;

		position:relative; z-index:1;
	}

	.confirmBtn2 {
		width: 120px;
		height:40px;
		font-size:18px;
	}

	.confirmBtn3 {
		width: 130px;
		height:50px;
		font-size:18px;
		margin-top:1px;
		background-image: -webkit-gradient(linear, left top, left bottom, from(#6699CC), to(#6699CC),color-stop(0.7,#6688CC));
		color: #fff;
		font-weight:bold;
		text-shadow: -1px 2px rgba(0,0,0,0.2);
		-webkit-border-radius:10px;

		position:relative; z-index:1;
	}
	.orderCompletionBtn {
		width: 120px;
		height:40px;
		font-size:18px;
	}

	.workComplete{
	 position:absolute;
	 bottom :230px;
	 left:640px;
	 visibility: visible;

	 width: 320px;
	 height:200px;
	}

	.orderBtn{
	width: 130px;
	height:50px;
	font-size:18px;
	margin-top:1px;
	background-image: -webkit-gradient(linear, left top, left bottom, from(#6699CC), to(#6699CC),color-stop(0.7,#6688CC));
	color: #fff;
	font-weight:bold;
	text-shadow: -1px 2px rgba(0,0,0,0.2);
	-webkit-border-radius:10px;

	position:relative; z-index:1;
}


</style>



<script language='javascript'>

//画面固定
//document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

var clsNKB = new CNumKeyBoard();

function onInit(){
	//入荷完了後、メッセーを出してメイン画面に遷移
	var stateFlg = "<%=formBean.getStateFlg()%>";
	var afterFunc="nextPageJump('odr3000');"
	if(stateFlg == "4"){
		//入荷取消を正常に完了しました
		alert_Info2("<%=Message.getMessage("INF00020").replace("$1", "余剰取消")%>",afterFunc);
	}
}


function nextPageJump(nextPage){
	mainForm = document.getElementById("F1");
	document.getElementById("nextPage").value = nextPage;

	mainForm.submit();
}




//パップアップ解除
function back(){
	document.getElementById("opAlertBtn").style.display = "none";
	document.getElementById("opAlert").style.display = "none";
	document.getElementById("opAlertButton").style.display = "none";
	document.getElementById("opAlertTop").style.display = "none";
	document.getElementById("allbackgr").style.display = "none";
}

//「入荷取消」ボタン押下
function undoBtn(){
	
	//確定時と入荷時の更新日を比較
	mRsvSupplyCheck();

}



function JSONConvert(node){
	var type = node.nodeType;
	if ( isTextNode(node) ){
		var text = getTextValue(node);
		return text;
	}
	if ( type==1 ){
		var json = {};
		var nodeName = node.nodeName;
		var childs = node.childNodes;

		for (var i = 0; i<childs.length; i++){
			var child = childs[i];
			var obj = json[child.nodeName];

			if ( child.nodeType == 1 ){
				if ( obj ){
					var array = null;
					if ( !isArray(obj) ){
						array=[];
						array[array.length]=obj;
					}else{
						array=json[child.nodeName];
					}
					array[array.length]=JSONConvert(child);
					json[child.nodeName]=array;
				}else{
					json[child.nodeName]=JSONConvert(child);
				}
			}
		}
		return json;
	}
}

function isTextNode(node){
	if ( node.hasChildNodes() ){
		var childs = node.childNodes;
		for (var i = 0; i<childs.length; i++){
			var child = childs[i];
			if ( child.nodeType != 3 ) return false;
		}
	}
	return true;
}

function getTextValue(node){
	if ( node.hasChildNodes() ){
		var childs = node.childNodes;
		var child = childs[0];
		if ( child.nodeType == 3 ){
			return child.nodeValue;
		}
	}
	return null;
}
//------------------------------------------------------------------------------

//*************************************************
//AJAX 部分(予備品Mから削除チェック)
//*************************************************
function mRsvSupplyCheck(){
	
	var findItemNo = document.getElementById("itemNo1").value+"-"+document.getElementById("itemNo2").value;
	
	var xmlHttp;

	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = checkStatus2;
	xmlHttp.open("GET", "../itm2099/itm2099?itemCd="+findItemNo, false);
	xmlHttp.send(null);

	function checkStatus2(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			var xml = xmlHttp.responseXML;
			var rootNodes = xml.getElementsByTagName("list");
			var rootNode = rootNodes[0];
			var json = JSONConvert(rootNode);
			if (json==null) {
			}else {
				//-----------------------------------------
				//削除チェック
				//-----------------------------------------
				var delDiv = json.deldiv;

				//削除の時はメッセージを表示
				if(delDiv == "1"){
					alert_Custom("<%=Message.getMessage("WRN01500").replace("$1", "入荷取消")%>");
					return;
				}
				updateDtCheck3();

			}
		}
	}
}

//*************************************************
//AJAX 部分(確定時と発注時の予備品入荷Tの更新日を比較)
//*************************************************
function updateDtCheck3(){
	mainForm = document.getElementById("F1");
	//------------------------------------------------------
	//入荷Tの確定時と発注時の更新日を比較
	var findOdrNo = document.getElementById("odrNo").value;
	
	var xmlHttp;

	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = checkStatus4;
	xmlHttp.open("GET","../inv2002/inv2002?odrNo="+findOdrNo,false);
	xmlHttp.send(null);

	function checkStatus4(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			var xml = xmlHttp.responseXML;
			var rootNodes = xml.getElementsByTagName("list");
			var rootNode = rootNodes[0];
			var json = JSONConvert(rootNode);
			if (json==null) {
			}else {
				var orderUpdateDt = json.updatedt;
				var confirmUdateDt = document.getElementById("updateDt_hid_odr").value;
				//確定時と発注時の更新日を比較
				if(orderUpdateDt == confirmUdateDt || orderUpdateDt == null){
					
					var afterFunc="yesUndoBtn();"
					if (!confirm_Custom3("<%=Message.getMessage("INF01110").replace("$1", "作業完了").replace("$2","入荷済")%>",afterFunc)){
						return;
					}
				}else{

					alert_Custom("<%=Message.getMessage("WRN01030").replace("$1", "余剰取消")%>");
					//予備品のマスタ情報が既に変更されています。発注を再度やり直して下さい。
					return;
				}

			}
		}
		//------------------------------------------------------
	}
}
//「はい」を押された時
function yesUndoBtn(){
	document.getElementById("undoExe").value = "1";
	mainForm = document.getElementById("F1");
	mainForm.submit();
}

</script>


</head>

<body onLoad="onInit()">
<form name="main" id="F1" action="./use2000" method="post" class="frmMain">
<%
//題名の設定
String headSubName="";
if("3".equals(strOutputCate)){
	headSubName = "完了";
}else if("4".equals(strOutputCate)){
	headSubName = "キャンセル";
}
%>
<table style="">
	<!--HEADER TITLE START -->
	<tr style = "background-color:#e1e1e1;  font-weight: bold;  border-bottom:1px solid #e1e1e1; background: -webkit-gradient(linear, left top, left bottom, from(#e1e1e1), to(#ffffff));　 ">
		<td colspan="2" class ="header_tbl" style = "font-size:22px; height:40px;"  align = "left">
			　予備品管理システム (<%=formBean.kojou%>)　　　
			<span style="font-size:30px; text-shadow:2px 2px #666; 	color:#aaa;">直結看板以外余剰登録画面（<%=headSubName%>）</span>
		</td>
	</tr>
	<!--HEADER TITLE END -->



	<!--メインメニュー画面　START  -->
	<tr style="height:628px; ">
<%
//バックカラーの設定
String backColor="";
if("3".equals(strOutputCate)){
	backColor="background: -webkit-gradient(linear, left top, left bottom, from(#F0FFFF), to(#F0FFFF));";
}else if("4".equals(strOutputCate)){
	backColor="background: -webkit-gradient(linear, left top, left bottom, from(#FFF0F5), to(#FFF0F5));";
}
%>
		<td class="right" style="<%=backColor%>"s>
			 <!--<div class="mainLine" id = "mainLine" style="display:inline; " ></div>  -->

			<table width ="100%"  class="mainTbl_Right">
				<!--発注 -->
				<tr>
					<td id="" align = "left"   class="selTitle" colspan="3">　発注方法:<input type="text" name="odrMeth" id="odrMeth" class="" style="width:150px; height:25px; font-size:15px; color: black; background-color:#CCC;" value="<%=formBean.getOdrMethNm()%>" readonly>
					</td>
				</tr>

				<tr>
					<td id="" align = "left"   class="selTitle">　Y品番:　
					<input type="text"  class="" name="itemNo1" id="itemNo1" style="width: 50px; height:25px; font-size:15px; color:blue;  background-color:#CCC;"  value="<%=formBean.getItemNo1()%>" readonly> -
					<input type="text"  class="" name="itemNo2" id="itemNo2" style="width: 50px; height:25px; font-size:15px; color:blue;  background-color:#CCC;" value="<%=formBean.getItemNo2()%>"  readonly>
					</td>

					<td id="" align = "left"   class="selTitle">　発注日:
						<input type="text"  class="" name="odrDt" id="odrDt" style="width: 100px; height:30px; font-size:15px; color:blue;background-color:#CCC;" value="<%=formBean.getOdrDt()%>" readonly>
					</td>

				</tr>
				<tr>
					<td id="" align = "left"  valign="top"  class="selTitle" colspan="3">　品名:　　
						<textarea name="" cols="40" rows="2" style="width:  510px; font-size:15px; color:blue; background-color:#CCC;" readonly  ><%=formBean.getItemNm()%></textarea>
					</td>
				</tr>
                <tr>
					<td id="" align = "left"  valign="top"  class="selTitle" colspan="3">　型式:　　
						<textarea name="" cols="40" rows="2" style="width:  510px; font-size:15px; color:blue; background-color:#CCC;"  readonly ><%=formBean.getModel()%></textarea>
					</td>
				</tr>
				<tr>
					<td id="" align = "left"   class="selTitle" colspan="2">　単価:　　
					<input type="text"  class="" name="" id="" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC; text-align:right;" readonly  value="<%=formBean.getUnitPrice()%>">
					　L/T:
					<input type="text"  class="" name="" id="" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC; text-align:right;" readonly  value="<%=formBean.getLeadTm()%>">
					　出庫オーダー:
					<%
					String delvOdr = "";
					Use2000Bean.PullData[] inputDelvOdrList = formBean.getInputDelvOdrList();
					for (int i = 0; inputDelvOdrList != null && i < inputDelvOdrList.length; i++) {
						Use2000Bean.PullData data = inputDelvOdrList[i];
						if(data.key.equals(formBean.getDelvOdr())){
							delvOdr = data.value;
						}
					}
					%>
					<input type="text"  class="" name="" id="" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=delvOdr%>">
					</td>
				</tr>
				<tr>
					<td id="" align = "left"   class="selTitle" colspan="2">　発注数量:
					<input type="text"  class="" name="orderNum" id="orderNum" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC; text-align:right;" readonly  value="<%=formBean.getOrderNum()%>">
					　手配連番:
					<input type="text"  class="" name="" id="" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getOdrSeq()%>"></td>
				</tr>


				<tr>
					<td id="" align = "left"   class="selTitle" colspan="2">　設備機番:
					<%
					String machineNm = "";
					Use2000Bean.PullData[] inputMachineNmList = formBean.getInputMachineNmList();
					for (int i = 0; inputMachineNmList != null && i < inputMachineNmList.length; i++) {
						Use2000Bean.PullData data = inputMachineNmList[i];
						if(data.key.equals(formBean.getMachineNo())){
							machineNm = data.value;
						}
					}
					%>
					<input type="text"  class="ReadStyle" name="machineNo" id="machineNo" style="width: 310px; height:25px; font-size:15px; color:blue; background-color:#CCC;" value="<%=machineNm%>" readonly></td>
				</tr>

				<tr>
					<td id="" align = "left"   class="selTitle" colspan="2">　入荷予定年月日:
					<input type="text"  class="" name="" id="" style="width: 100px; height:33px; font-size:15px; color:blue; background-color:#CCC;" readonly   value="<%=formBean.getArrPlanDt()%>" readonly>
					　入荷年月日:
					<input type="text"  class="" name="" id="" style="width: 100px; height:33px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getArrDt()%>" readonly></td>
				</tr>

				<!--線を引く -->
				<tr ><td  colspan="4"><hr></td></tr>

				<tr>
					<td id="" align = "left"   class="selTitle" colspan="2">　発注担当者:
						<input type="text"  class="" name="" id="" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getOdrUsrKumi()%>">
						<input type="text"  class="" name="" id="" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getOdrUsr()%>">
					</td>


					<td id="" align="left"   class="selTitle">使用者:
						<input type="text"  class="" name="useUsrKey" id="useUsrKey" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getUseUsr()%>">
					</td>
				</tr>

				<tr>
					<td id="" align = "left"   class="selTitle" colspan="2">　入荷担当者:
						<input type="text"  class="" name="" id="" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getArrUsrKumi()%>">
						<input type="text"  class="" name="" id="" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getArrUsr()%>">
					</td>
				</tr>

				<tr>
					<td id="" align = "left"   class="selTitle" colspan="2">　完了担当者:
						<input type="text" name="odrUsr"  id="odrUsr"  style="width:100px; height:30px; font-size:15px; color:blue;background-color:#CCC;" value="<%=formBean.getCompUsrKumi_hid()%>"readonly>
						<input type="text" name="usrList"  id="usrList"  style="width:100px; height:30px; font-size:15px; color:blue;background-color:#CCC;" value="<%=formBean.getCompUsr_hid()%>" readonly>
					</td>
				</tr>
			</table>

			<!-- 発注理由 -->
			<div class="OrderReason">
			<table border="1" style="border-color: #CCCCCF;">
				<tr>
					<td>　【発注理由】</td>
				</tr>
				<tr>
					<td id="" align="left"   class="selTitle">　使用設備:　
						<input type="text"  class="" name="" id="" style="width: 180px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly value="<%=formBean.getUseFacil()%>" readonly>
					</td>
				</tr>
				<tr>
					<td id="" align="left"   class="selTitle">　使用用途:　
						<input type="text"  class="" name="" id="" style="width: 180px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly value="<%=formBean.getUseMeth()%>" readonly>
					</td>
				</tr>
				<tr>
					<td id="" align="left"   class="selTitle">　使用予定日:
						<input type="text"  class="" name="" id="" style="width: 100px; height:30px; font-size:15px; color:blue; background-color:#CCC;" readonly value="<%=formBean.getUsePlanDt()%>" readonly>
					</td>
				</tr>
			</table>
			</div>


			<div class="bottomBtn">
				<table>
					<tr>
						<td></td>
						<td align = "right" >

						</td>
						<td align = "right" >
							<input type="button"  onclick="undoBtn();" class="orderBtn"  value="余剰取消">　　
						</td>
						<td align = "right" >
							<input type="button"  onclick="nextPageJump('odr3000');" class="backBtn"  value="戻る">　
						</td>
					</tr>
				</table>
			</div>




			<!-- 作業完了 -->
			<div class="workComplete">
			<table border="1" style="border-color: #CCCCCF;">
				<tr>
					<td>　【作業完了】</td>
				</tr>
				<tr>
					<td id="" align = "left"   class="selTitle" >　作業完了日:
					<input type="text"  class="" name="compDt" id="compDt" style="width: 100px; height:30px; font-size:15px; color:blue; background-color:#CCC;"  value="<%=formBean.getCompDt().replace("-","/")%>" readonly>
					</td>

				</tr>
				<tr>
					<td id="" align="left"   class="selTitle" >　使用数量:　
					<input type="text"  class="useNum" name="useNum" id="useNum"  style="width: 100px; height:25px; font-size:15px; color:blue; text-align:right; background-color:#CCC;"  value="" readonly>
					<input type="text"  class="" name="" id="" style="width: 50px; height:25px; font-size:15px; color:blue; background-color:#CCC; text-align:right;" readonly  value="<%=formBean.getUseNum() %>/<%=formBean.getOrderNum()%>">
					</td>
				</tr>

				<tr>
					<td id="" align="left"  class="selTitle">　保管場所:　
						<%
						String strageArea="";
						Use2000Bean.PullData[] inputStrageArea = formBean.getInputStrageArea();
						for (int i = 0; inputStrageArea != null && i < inputStrageArea.length; i++) {
							Use2000Bean.PullData data = inputStrageArea[i];
							if(data.key.equals(formBean.getStrageArea_hid())){
								strageArea = data.value;
							}
						}
						%>
						<input type="text" name="strageArea"  id="strageArea"  style="width:187px; height:30px; font-size:15px; color:blue; background-color:#CCC;" value="<%=strageArea %>" readonly>
					</td>
				</tr>
			</table>
			</div>

			<!--ログインMAIN画面　END  -->

		</td>
	</tr>
</table>
	<div class='footer' align='right' style="font-size:35px; background-image: url(../../common/img/toyotaB.png); background-repeat: no-repeat; align:top;" ></div> 
<!-- <div class='ImageZone' align='right' style="font-size:20px; align:top"><img src='../../common/img/XXX.gif' height='180px' width='200px'></div>  -->
	<div id="NumKeyBoardID"></div>


	<!--警告 ポップアップ---------------------------------------------------------------------------- -->
	<div id="allbackgr" class="allbackgr" style="display:none;"></div>
	<div class="opAlertBtn" id = "opAlertBtn" style="display:none;" ></div>
	<div class="opAlertButton" id = "opAlertButton" style="display:none;" ></div>
	<div class="opAlertTop" id = "opAlertTop" style="display:none; font-size:22px;">　予備品管理システム　</div>
	<div class="opAlert" id = "opAlert" style="display:none;"></div>
	<!-- -------------------------------------------------------------------------------------------- -->


	<input type="hidden" id="outputCate" name="outputCate" value="<%=formBean.getOutputCate()%>">
	<input type="hidden" id="nextPage" name="nextPage" value="">
	<input type="hidden" id="usrListKey" name="usrListKey" value="">
	<input type="hidden" id="undoExe" name="undoExe" value="">
	<input type="hidden" id="odrNo" name="odrNo" value="<%=formBean.getOdrNo()%>">
	<input type="hidden" id="updateDt_hid_odr" name="updateDt_hid_odr" value="<%=formBean.getUpdateDt_hid_odr() %>">
	<input type="hidden" id="displayCate" name="displayCate" value="<%=formBean.getDisplayCate() %>">

</form>
</body>
</html>
